{
 "cells": [
  {
   "cell_type": "markdown",
   "id": "66eb942b",
   "metadata": {},
   "source": [
    "## 上周回顾\n",
    "\n",
    "> * 1.list的一般方法/函数的使用及案例，如：\n",
    ">> 1. append（）增加，增加list元素到list的末尾，常用于新建列表\n",
    ">> 2. pop（index）/remove（values）对比两者优势\n",
    ">> 3. count（）查看某个元素出现的次数\n",
    ">> 4. index（）查看某个元素第一次出现的位置\n",
    ">> 5. extend（）两个list合并在一起，也可以用[]+[]来实现\n",
    ">> 6. sort（）list元素的排序\n",
    "\n",
    "> * 2.list的高级用法，如：\n",
    ">> 1. copy（）list（可变的数据类型）复制不等于赋值，可用[:]来实现\n",
    ">> 2. enumerate（）枚举，可同时遍历并获取index和values\n",
    "\n",
    "## 本周内容：\n",
    "\n",
    "### list练习，vowels.py vowels2.py\n",
    "\n",
    "### list实践：\n",
    "\n",
    "### 初始字典：\n",
    "\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "094ea953",
   "metadata": {},
   "outputs": [],
   "source": [
    "vowels = ['a','e','i','o','u']\n",
    "word = 'Milliways'\n",
    "#  检查word中出现的元音，并打印出来 怎么做？\n",
    "#  for letter in word: # 第一个元素letter 请不要和已有变量重名\n",
    "                      # 第一个元素一般不定义名字，常用item（元素）来命名\n",
    "                      #                       简写i来命名\n",
    "                      # 第二个元素（重要），意味着将遍历的内容\n",
    "                      # 遍历的内容一般是 序列数据 str\n",
    "for letter in word:\n",
    "\n",
    " print(letter)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 11,
   "id": "ab230072",
   "metadata": {},
   "outputs": [
    {
     "ename": "SyntaxError",
     "evalue": "unmatched ')' (<ipython-input-11-c93c7f779519>, line 27)",
     "output_type": "error",
     "traceback": [
      "\u001b[0;36m  File \u001b[0;32m\"<ipython-input-11-c93c7f779519>\"\u001b[0;36m, line \u001b[0;32m27\u001b[0m\n\u001b[0;31m    print('商品编号：%s，商品编号：%s，商品价格：%s 元'%(i,goods_list[i][0]),goods_list[i],[1]))\u001b[0m\n\u001b[0m                                                                             ^\u001b[0m\n\u001b[0;31mSyntaxError\u001b[0m\u001b[0;31m:\u001b[0m unmatched ')'\n"
     ]
    }
   ],
   "source": [
    "# 商品信息的数据存放（商品名称，商品价格，商品的编号）\n",
    "goods_list = [\n",
    "    ['iphone13',6000],     # 我们认为 每一个商品的内容是一个多个值的值，可选用list\n",
    "    ['ipad',5000],\n",
    "    ['macbook pro',9999],\n",
    "    ['iwatch',3000],\n",
    "    ['coffee',30],\n",
    "                ]\n",
    "# 用户购物信息的数据存放\n",
    "Alipay = input('请输入支付宝的余额：')\n",
    "# 打印商品信息\n",
    "# info = '''-----goods list------\n",
    "# 商品编号：%s，商品编号：%s，商品价格：%s 元\n",
    "# 商品编号：%s，商品编号：%s，商品价格：%s 元\n",
    "# 商品编号：%s，商品编号：%s，商品价格：%s 元\n",
    "# 商品编号：%s，商品编号：%s，商品价格：%s 元\n",
    "# '''%(0,goods_list[0][0],goods_list[0][1],\n",
    "#      1,goods_list[1][0],goods_list[1][1],\n",
    "#      2,goods_list[2][0],goods_list[2][1],\n",
    "#      3,goods_list[3][0],goods_list[3][1],\n",
    "#     )\n",
    "# print(info)\n",
    "\n",
    "#list的长度？len（）\n",
    "print('-----goods list-----')\n",
    "for i in range(len(goods_list)):\n",
    "    print('商品编号：%s，商品编号：%s，商品价格：%s 元'%(i,goods_list[i][0],goods_list[i],[1])\n",
    "         )\n",
    "\n",
    "# 用户输入商品编号，实现商品的查询\n",
    "choice = int(input('请输入商品的编号:'))     # input输入的内容默认是字符串str 例如输入2，则显示2\n",
    "# 判断编号是否存在\n",
    "if choice < len(goods_list):\n",
    "    # 检查 用户余额 > 商品价格\n",
    "    if Alipay > goods_list[choice][1]:\n",
    "    Alipay = Alipay - goods_list[choice][1]  # 用户余额发生变化，要扣除\n",
    "else:\n",
    "    print('请输入正确的商品编号，您输入的商品不存在')\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "8500e16a",
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "hide_input": false,
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.8.8"
  },
  "toc": {
   "base_numbering": 1,
   "nav_menu": {},
   "number_sections": true,
   "sideBar": true,
   "skip_h1_title": false,
   "title_cell": "Table of Contents",
   "title_sidebar": "Contents",
   "toc_cell": false,
   "toc_position": {},
   "toc_section_display": true,
   "toc_window_display": false
  },
  "varInspector": {
   "cols": {
    "lenName": 16,
    "lenType": 16,
    "lenVar": 40
   },
   "kernels_config": {
    "python": {
     "delete_cmd_postfix": "",
     "delete_cmd_prefix": "del ",
     "library": "var_list.py",
     "varRefreshCmd": "print(var_dic_list())"
    },
    "r": {
     "delete_cmd_postfix": ") ",
     "delete_cmd_prefix": "rm(",
     "library": "var_list.r",
     "varRefreshCmd": "cat(var_dic_list()) "
    }
   },
   "types_to_exclude": [
    "module",
    "function",
    "builtin_function_or_method",
    "instance",
    "_Feature"
   ],
   "window_display": false
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
